from urllib.error import URLError
from urllib.request import ProxyHandler,build_opener

#创建ProxyHandler对象，并指定HTTP和HTTPS代理的IP和端口号
proxy_handler=ProxyHandler({
    'http':'http://182.86.191.16:24695',
    'https':'https://182.86.191.16:24695'
})
opener=build_opener(proxy_handler)
try:
    response=opener.open('https://www.jd.com')
    print(response.read().decode('utf-8'))
except URLError as e:
    print(e.reason)

#若指定的端口是正确的，就可以正常输出响应的结果